package com.zhou.jiancai.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.zhou.jiancai.R;
import com.zhou.jiancai.ui.SpiderView.SpiderView;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

import rorbin.q.radarview.RadarData;


/**
 * Created by Administrator on 2017/5/9.
 */

public class SpiderActivity extends Activity {

    SpiderView radarView;
    private RadarData data;
    private Random random;
    private Random random1;
    private SpiderView radarView1;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // https://github.com/zhouzhixue/RadarChart
        setContentView(R.layout.spideractivity);

        initData();
        initView();

    }






    private void initView() {
        radarView = (SpiderView) findViewById(R.id.radarView);
    }



    private void initData() {
        List<Float> values = new ArrayList<>();
        random1 = new Random();
        for (int i = 0; i <10 ; i++) {
          float a=  random1.nextInt(10);
            values.add(a);
        }

        Collections.addAll(values);
        data = new RadarData(values);
     //加载数据
        List <Integer> colorlist=new ArrayList();

        for (int i = 0; i <values.size() ; i++) {
            //循环生成随机颜色
            random1 = new Random();
            int ranColor = 0xff000000 | random1.nextInt(0x00ffffff);

            colorlist.add(ranColor);
        }


        radarView.setLayerColor(colorlist);
        radarView.addData(data);
        List <String> textlist=new ArrayList<>();
        textlist.add("能量")   ;
        textlist.add("交流")   ;
        textlist.add("生活")   ;
        textlist.add("激情")   ;
        textlist.add("智慧")   ;
        //设置定点文字内容
        radarView.setVertexText(textlist);
        //展现动画
        radarView.animeValue(500,data);
        //设置各层的颜色


    }
}
